import { immerable, produce } from "immer";
class Address {
  [immerable] = true;
  street: string;
  city: string;

  constructor(street: string, city: string) {
    this.street = street;
    this.city = city;
  }
}

class User {
  [immerable] = true;
  name: string;
  address: Address;

  constructor(name: string, address: Address) {
    this.name = name;
    this.address = address;
  }
}

const user = new User("Alice", new Address("123 Main St", "Anytown"));
const updatedUser = produce(user, (draft) => {
  draft.address.street = "456 Elm St";
  draft.address.city = "Othertown";
});

console.log(updatedUser);
